////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2017-2018 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// THIS IS AUTO-GENERATED CODE.  PLEASE DO NOT EDIT (File bug reports against tools).
///
/// Auto-generated by: ParameterParser V1.1.4
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file  afhafelements.cpp
/// @brief Auto-generated Chromatix parameter file
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "afhafelements.h"
#include "parametersetmanager.h"

AFHAFELEMENTS_NAMESPACE_BEGIN

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Default Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
chromatixHAFTypeClass::chromatixHAFTypeClass(
    const CHAR* name)
    : ParameterModule(name, MAJOR, MINOR, PATCH, 0, 0, 0, 0)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(parameter_version);
    PARAMETER_INITIALIZE(enable_section);
    PARAMETER_INITIALIZE(statsConsumeEnableCount);
    PARAMETER_INITIALIZE(statsConsumeEnableID);
    PARAMETER_INITIALIZE(statsConsumeEnable);
    PARAMETER_INITIALIZE(statsSelect);
    PARAMETER_INITIALIZE(fineSearchDropThreshold);
    PARAMETER_INITIALIZE(fineStepSize);
    PARAMETER_INITIALIZE(maxMoveStep);
    PARAMETER_INITIALIZE(maxMoveStepBuffer);
    PARAMETER_INITIALIZE(baseFrameDelay);
    PARAMETER_INITIALIZE(AFFineSearchExtension);
    PARAMETER_INITIALIZE(sceneChangeDuringFS);
    PARAMETER_INITIALIZE(faceCAFHighPriorityEnable);
    PARAMETER_INITIALIZE(enableInitialPosition);
    PARAMETER_INITIALIZE(initialLensIdx);
    PARAMETER_INITIALIZE(depthConfidenceCountThreshold);
    PARAMETER_INITIALIZE(HAFROISettings);
    PARAMETER_INITIALIZE(HAFFollowerSettings);
    PARAMETER_INITIALIZE(macroRegionThresholdInMM);
    PARAMETER_INITIALIZE(farRegionThresholdinMM);
    PARAMETER_INITIALIZE(fineStartMoveBuffer);
    PARAMETER_INITIALIZE(DOFMultiplier);
    PARAMETER_INITIALIZE(enableForceScanEnd);
    PARAMETER_INITIALIZE(enablePassiveScanTimeout);
    PARAMETER_INITIALIZE(maxScanCountThreshold);
    PARAMETER_INITIALIZE(gyroSettings);
    PARAMETER_INITIALIZE(enableDynamicAnchorPoints);
    PARAMETER_INITIALIZE(anchorPosition1);
    PARAMETER_INITIALIZE(anchorPosition2);
    PARAMETER_INITIALIZE(minimumFocusIndex);
    PARAMETER_INITIALIZE(HJNormalizedWeightType);
    PARAMETER_INITIALIZE(CAFHJNormalizedWeightType);
    PARAMETER_INITIALIZE(AFControlAECInfoEnable);
    PARAMETER_INITIALIZE(AFControlAECInfoFPS);
    PARAMETER_INITIALIZE(spd_stats_type);
    PARAMETER_INITIALIZE(spd_bg_stats_thresh_auto_convert_enable);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
chromatixHAFTypeClass::chromatixHAFTypeClass(
    const CHAR* name,
    UINT32 modeId,
    UINT16 mode,
    UINT16 subMode,
    UINT32 group)
    : ParameterModule(name, MAJOR, MINOR, PATCH, modeId, mode, subMode, group)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(parameter_version);
    PARAMETER_INITIALIZE(enable_section);
    PARAMETER_INITIALIZE(statsConsumeEnable);
    PARAMETER_INITIALIZE(statsSelect);
    PARAMETER_INITIALIZE(fineSearchDropThreshold);
    PARAMETER_INITIALIZE(fineStepSize);
    PARAMETER_INITIALIZE(maxMoveStep);
    PARAMETER_INITIALIZE(maxMoveStepBuffer);
    PARAMETER_INITIALIZE(baseFrameDelay);
    PARAMETER_INITIALIZE(AFFineSearchExtension);
    PARAMETER_INITIALIZE(sceneChangeDuringFS);
    PARAMETER_INITIALIZE(faceCAFHighPriorityEnable);
    PARAMETER_INITIALIZE(enableInitialPosition);
    PARAMETER_INITIALIZE(initialLensIdx);
    PARAMETER_INITIALIZE(depthConfidenceCountThreshold);
    PARAMETER_INITIALIZE(HAFROISettings);
    PARAMETER_INITIALIZE(HAFFollowerSettings);
    PARAMETER_INITIALIZE(macroRegionThresholdInMM);
    PARAMETER_INITIALIZE(farRegionThresholdinMM);
    PARAMETER_INITIALIZE(fineStartMoveBuffer);
    PARAMETER_INITIALIZE(DOFMultiplier);
    PARAMETER_INITIALIZE(enableForceScanEnd);
    PARAMETER_INITIALIZE(enablePassiveScanTimeout);
    PARAMETER_INITIALIZE(maxScanCountThreshold);
    PARAMETER_INITIALIZE(gyroSettings);
    PARAMETER_INITIALIZE(enableDynamicAnchorPoints);
    PARAMETER_INITIALIZE(anchorPosition1);
    PARAMETER_INITIALIZE(anchorPosition2);
    PARAMETER_INITIALIZE(minimumFocusIndex);
    PARAMETER_INITIALIZE(HJNormalizedWeightType);
    PARAMETER_INITIALIZE(CAFHJNormalizedWeightType);
    PARAMETER_INITIALIZE(AFControlAECInfoEnable);
    PARAMETER_INITIALIZE(AFControlAECInfoFPS);
    PARAMETER_INITIALIZE(spd_stats_type);
    PARAMETER_INITIALIZE(spd_bg_stats_thresh_auto_convert_enable);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Destructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
chromatixHAFTypeClass::~chromatixHAFTypeClass()
{
    UnloadchromatixHAFType(this);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// GetName
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const CHAR* chromatixHAFTypeClass::GetName(
    const CHAR* type)
{
    const CHAR* name = type;
    CHAR temp[ParameterFileSymbolTableEntry::TYPE_LEN + 1];
    if (PARAMETER_STRCMP(type, ParameterFileSymbolTableEntry::GetType(temp, "chromatixHAF")) == 0)
    {
        name = "chromatixHAF";
    }
    return name;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixAFFineSearchExtensionType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixHAFTypeClass::LoadchromatixAFFineSearchExtensionType(
    ParameterFileSymbolTableEntry* entry,
    chromatixAFFineSearchExtensionType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadUInt32(&structure->enable);
    result = result && entry->ReadInt32(&structure->maximumFineSearchExtensionCount);
    result = result && entry->ReadInt32(&structure->numNearSteps);
    result = result && entry->ReadInt32(&structure->numFarSteps);
    result = result && entry->ReadInt32(&structure->stepSize);
    result = result && entry->ReadFloat(&structure->decreaseDropRatio);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixHAFGyroSettingsType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixHAFTypeClass::LoadchromatixHAFGyroSettingsType(
    ParameterFileSymbolTableEntry* entry,
    chromatixHAFGyroSettingsType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->enableGyroSamplingRateAdjustment);
    result = result && entry->ReadFloat(&structure->gyroSamplingRateMonitor);
    result = result && entry->ReadFloat(&structure->gyroSamplingRateSearching);
    result = result && entry->ReadFloat(&structure->gyroSamplingRateSearchingHJ);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixAFFollowerStepType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixHAFTypeClass::LoadchromatixAFFollowerStepType(
    ParameterFileSymbolTableEntry* entry,
    chromatixAFFollowerStepType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->stepSize);
    result = result && entry->ReadInt32(&structure->numFarSteps);
    result = result && entry->ReadInt32(&structure->numNearSteps);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixSearchInfoType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixHAFTypeClass::LoadchromatixSearchInfoType(
    ParameterFileSymbolTableEntry* entry,
    chromatixSearchInfoType* structure)
{
    BOOL result = TRUE;
    result = result && LoadchromatixAFFollowerStepType(entry, &structure->AFFollowerMacroRange);
    result = result && LoadchromatixAFFollowerStepType(entry, &structure->AFFollowerMidRange);
    result = result && LoadchromatixAFFollowerStepType(entry, &structure->AFFollowerFarRange);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixFollowerFineSearchInfoType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixHAFTypeClass::LoadchromatixFollowerFineSearchInfoType(
    ParameterFileSymbolTableEntry* entry,
    chromatixFollowerFineSearchInfoType* structure)
{
    BOOL result = TRUE;
    result = result && LoadchromatixSearchInfoType(entry, &structure->normalLightFineSearchInfo);
    result = result && LoadchromatixSearchInfoType(entry, &structure->lowLightFineSearchInfo);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixHAFFollowerSettingsType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixHAFTypeClass::LoadchromatixHAFFollowerSettingsType(
    ParameterFileSymbolTableEntry* entry,
    chromatixHAFFollowerSettingsType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->enableFollower);
    result = result && LoadchromatixFollowerFineSearchInfoType(entry, &structure->AFFollowerFineSearchSettings);
    result = result && entry->ReadInt32(&structure->enableGravityCompensationForFollower);
    result = result && entry->ReadInt32(&structure->jumpToStartLimitForFollower);
    result = result && entry->ReadInt32(&structure->lowLightThresholdForFollower);
    result = result && entry->ReadInt32(&structure->useFineSearchExtensionForFollower);
    result = result && entry->ReadInt32(&structure->activeConvergenceFollowForFollower);
    result = result && entry->ReadInt32(&structure->lensPosThresholdForActiveConvergenceFollow);
    result = result && entry->ReadInt32(&structure->searchStrategy);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixHAFROISettingsType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixHAFTypeClass::LoadchromatixHAFROISettingsType(
    ParameterFileSymbolTableEntry* entry,
    chromatixHAFROISettingsType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->HAFROIEnable);
    result = result && entry->ReadInt32(&structure->HAFROIHNum);
    result = result && entry->ReadInt32(&structure->HAFROIVNum);
    result = result && entry->ReadFloat(&structure->HAFCenterROISize);
    result = result && entry->ReadFloat(&structure->HAFCornerROISize);
    result = result && entry->ReadInt32(&structure->HAFROIDelay);
    result = result && entry->ReadInt32(&structure->enableROIShifting);
    result = result && entry->ReadInt32(&structure->ROIShiftType);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixHAFType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixHAFTypeClass::LoadchromatixHAFType(
    ParameterFileSymbolTableEntry* entry,
    chromatixHAFType* structure)
{
    BOOL result = TRUE;
    result = result && Loadmodule_versionStruct(entry, &structure->module_version);
    result = result && Loadparameter_versionStruct(entry, &structure->parameter_version);
    result = result && Loadenable_sectionStruct(entry, &structure->enable_section);

    // Reading structure->statsConsumeEnable from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->statsConsumeEnableCount);
        structure->statsConsumeEnableID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->statsConsumeEnable   = PARAMETER_NEW UINT32[structure->statsConsumeEnableCount];
        }
        if (!result || structure->statsConsumeEnable == NULL)
        {
            structure->statsConsumeEnableCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->statsConsumeEnableCount; i++)
        {
            result = result && pointerEntry1->ReadUInt32(&structure->statsConsumeEnable[i]);
        }
    }
    structure->statsSelect = (chromatixAFFocusValueStatsType)entry->ReadEnum(&result);
    result = result && entry->ReadFloat(&structure->fineSearchDropThreshold);
    result = result && entry->ReadInt32(&structure->fineStepSize);
    result = result && entry->ReadInt32(&structure->maxMoveStep);
    result = result && entry->ReadInt32(&structure->maxMoveStepBuffer);
    result = result && entry->ReadInt32(&structure->baseFrameDelay);
    result = result && LoadchromatixAFFineSearchExtensionType(entry, &structure->AFFineSearchExtension);
    result = result && entry->ReadInt32(&structure->sceneChangeDuringFS);
    result = result && entry->ReadInt32(&structure->faceCAFHighPriorityEnable);
    result = result && entry->ReadInt32(&structure->enableInitialPosition);
    result = result && entry->ReadInt32(&structure->initialLensIdx);
    result = result && entry->ReadInt32(&structure->depthConfidenceCountThreshold);
    result = result && LoadchromatixHAFROISettingsType(entry, &structure->HAFROISettings);
    result = result && LoadchromatixHAFFollowerSettingsType(entry, &structure->HAFFollowerSettings);
    result = result && entry->ReadFloat(&structure->macroRegionThresholdInMM);
    result = result && entry->ReadFloat(&structure->farRegionThresholdinMM);
    result = result && entry->ReadInt32(&structure->fineStartMoveBuffer);
    result = result && entry->ReadFloat(&structure->DOFMultiplier);
    result = result && entry->ReadInt32(&structure->enableForceScanEnd);
    result = result && entry->ReadInt32(&structure->enablePassiveScanTimeout);
    result = result && entry->ReadInt32(&structure->maxScanCountThreshold);
    result = result && LoadchromatixHAFGyroSettingsType(entry, &structure->gyroSettings);
    result = result && entry->ReadInt32(&structure->enableDynamicAnchorPoints);
    result = result && entry->ReadInt32(&structure->anchorPosition1);
    result = result && entry->ReadInt32(&structure->anchorPosition2);
    result = result && entry->ReadInt32(&structure->minimumFocusIndex);
    result = result && entry->ReadInt32(&structure->HJNormalizedWeightType);
    result = result && entry->ReadInt32(&structure->CAFHJNormalizedWeightType);
    result = result && entry->ReadInt32(&structure->AFControlAECInfoEnable);
    result = result && entry->ReadInt32(&structure->AFControlAECInfoFPS);
    result = result && entry->ReadInt32(&structure->spd_stats_type);
    result = result && entry->ReadInt32(&structure->spd_bg_stats_thresh_auto_convert_enable);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load module_versionStruct
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixHAFTypeClass::Loadmodule_versionStruct(
    ParameterFileSymbolTableEntry* entry,
    chromatixHAFType::module_versionStruct* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->major_revision);
    result = result && entry->ReadInt32(&structure->minor_revision);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load parameter_versionStruct
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixHAFTypeClass::Loadparameter_versionStruct(
    ParameterFileSymbolTableEntry* entry,
    chromatixHAFType::parameter_versionStruct* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->major_revision);
    result = result && entry->ReadInt32(&structure->minor_revision);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load enable_sectionStruct
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixHAFTypeClass::Loadenable_sectionStruct(
    ParameterFileSymbolTableEntry* entry,
    chromatixHAFType::enable_sectionStruct* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->CAFEnable);
    result = result && entry->ReadInt32(&structure->PDAFEnable);
    result = result && entry->ReadInt32(&structure->TOFEnable);
    result = result && entry->ReadInt32(&structure->DCIAFEnable);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload chromatixHAFType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void chromatixHAFTypeClass::UnloadchromatixHAFType(
    chromatixHAFType* structure)
{
    PARAMETER_DELETE[] structure->statsConsumeEnable;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Parse symbol table entry, and return a new object
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ParameterModule* chromatixHAFTypeClass::Parse(
    ParameterSetManager* manager,
    ParameterFileSymbolTableEntry* entry) const
{
    chromatixHAFTypeClass* cls = NULL;

    if (PARAMETER_STRCMP(Type, entry->Type) == 0 && Major == entry->Major &&
        Minor == entry->Minor && Patch == entry->Patch)
    {
        cls = PARAMETER_NEW chromatixHAFTypeClass(GetName(entry->Type), 
            entry->ModeId, entry->Mode, entry->SubMode, entry->Group);
        if (cls != NULL)
        {
            BOOL result = TRUE;

            cls->SymbolTableID = entry->ID;
            cls->ID            = entry->ID;

            result = result && LoadchromatixHAFType(entry, cls);

            if (!result)
            {
                PARAMETER_DELETE cls;
                cls = NULL;
            }
        }
    }
    return (ParameterModule*)cls;
}


AFHAFELEMENTS_NAMESPACE_END
